# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=hlsl2glsl

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=r749.9af03c9
pkgrel=1
pkgdesc="HLSL to GLSL shader language translator"
arch=('any')
url='https://github.com/mingwandroid/hlsl2glslfork'
license=('MIT')
depends=("")
makedepends=("git" "${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-gcc")
optdepends=()
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
options=('!strip' 'staticlibs' '!emptydirs')
source=("${_realname}"::"git+https://github.com/mingwandroid/hlsl2glslfork.git#branch=say-hello-to-qbs"
    0001-Fix-CMakeLists.txt.patch
    0002-Generalize-CMakeLists.txt-a-bit.patch
    0003-MinGW-w64-build-fixes-for-hlsl2glsltest.cpp.patch
    )
md5sums=('SKIP'
         '30240eff0c158e302b34c880dc961bef'
         '76d65ee71bc4f32ece29822221c4dd6e'
         '493f2b1579556df1211d9df7d0c06d79')

pkgver() {
  cd "$srcdir/${_realname}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$srcdir/${_realname}"
  patch -p1 -i ${srcdir}/0001-Fix-CMakeLists.txt.patch
  patch -p1 -i ${srcdir}/0002-Generalize-CMakeLists.txt-a-bit.patch
  patch -p1 -i ${srcdir}/0003-MinGW-w64-build-fixes-for-hlsl2glsltest.cpp.patch
}

build() {
    cd ${srcdir}/${_realname}
  
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles"
    
    BISON_SIMPLE=${srcdir}/${_realname}/tools/bison.simple make
}

package() {
    cd ${srcdir}/${_realname}
    mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,include}
  cp *.exe ${pkgdir}${MINGW_PREFIX}/bin/
  cp include/hlsl2glsl.h ${pkgdir}${MINGW_PREFIX}/include/
  cp libhlsl2glsl.a ${pkgdir}${MINGW_PREFIX}/lib/
}

